import service from '@/utils/request'

export function getAllBusiness() {
  return service({
    url: `/orgs/ents/get`,
    method: 'get'
  })
}

export function getBusiness(pageNum: number, pageSize: number) {
  return service({
    url: `/orgs/ents/${pageNum}/${pageSize}`,
    method: 'get'
  })
}
//提交表单显示服务器端出错
export async function addBusiness(data: object) {
  return await service({
    url: `/orgs/ents/`,
    method: 'post',
    data
  })
}

export function searchBusiness(queryInfo: string, pageIndex: number, pageSize: number) {
  console.log(queryInfo, pageIndex)
  return service({
    url: `/orgs/ents/byName/${pageIndex}/${pageSize}?name=${queryInfo}`,
    method: 'get',
  })
}

export function searchBusinessByArea(queryInfo: string, pageIndex: number, pageSize: number) {
  // console.log(queryInfo, pageIndex)
  return service({
    url: `/orgs/ents/byCity/${pageIndex}/${pageSize}?cityId=${queryInfo}`,
    method: 'get',
  })
}

export function updateBusiness(id: string, data: any) {
  return service({
    url: `/orgs/ents/${id}`,
    method: 'put',
    data
  })
}

export function deleteBusiness(id: string) {
  return service({
    url: `/orgs/ents/${id}`,
    method: 'delete',
  })
}

export function importBdDeptdoc(data: any) {
  return service({
    url: '/orgs/ents/excelFile/',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function exportOrainationExcel() {
  return service({
    responseType: 'blob',
    url: '/orgs/ents/authExcel/export',
    method: 'get',
  })
}

export function uploadBusExcel(data: any) {
  return service({
    // url: '/minio/upload',
    url: '/orgs/ents/authExcelFile/',
    method: 'post',
    data,
    // headers: {
    //   'Content-Type': 'multipart/form-data'
    // }
  })
}